﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBA.Common;
using DBA.Data;
using DBA.Data.ADO;
using DBA.Web.UI;
using DBA.Model;


namespace DBA.Web.PublicService
{
    public partial class PublicServiceShow  : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ViewState["EmployeeID"] = RequestHelper.QueryString("EmployeeID");
            ViewState["Year"] = RequestHelper.QueryString("year");
            if (IsPostBack) return;

            SetCondition();
        }

        private void SetCondition()
        {
            if (VerificationHelper.IsNullOrEmpty(ViewState["EmployeeID"]))
            {
                return;
            }
            IList<AdoCondition> dict = new List<AdoCondition>();
            //dict.Add(new AdoCondition(CompareOper.equal, LogicOper.and, "EmployeeID", ServerContext.AdminCurrentUser.EmployeeID));

            //if (!VerificationHelper.IsNullOrEmpty<string>(txtYear.Text))
            //{
            //    dict.Add(new AdoCondition(CompareOper.like, LogicOper.and, "Year", txtYear.Text));
            //}  
            dict.Add(new AdoCondition(CompareOper.equal, LogicOper.and, "EmployeeID", ConvertHelper.ToInt32(ViewState["EmployeeID"])));
            dict.Add(new AdoCondition(CompareOper.equal, LogicOper.and, "Year", ConvertHelper.ToInt32(ViewState["Year"])));
            dict.Add(new AdoCondition("TpsID", OrderTypes.desc));
            ViewState["conditions"] = dict;
            Bind(1, dict);
        }

        DataAccessLibrary dal = CommonQuery.DataAccessLibrary;


        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            IList<AdoCondition> dict = null;
            if (ViewState["conditions"] != null)
            {
                dict = (IList<AdoCondition>)ViewState["conditions"];
            }
            Bind(e.NewPageIndex, dict);
        }

        private void Bind(int pageIdx, IList<AdoCondition> conditionList)
        {
            int iCount = 0;
            replData.DataSource = dal.ModifyData.Select<TeacherPublicService>(conditionList, pageIdx, 10, ref iCount);
            replData.DataBind();
            AspNetPager1.RecordCount = iCount;

        }


        protected void lnkDownload_Click(object sender, EventArgs e)
        {
            //BllStudentInfo bllStudent = new BllStudentInfo();
            //NPOIHelper.ExportByWeb(bllStudent.GetStudentInfoExcel(), string.Empty, "学生信息" + new Random().Next().ToString() + ".xls");
        }

    }
}
